<?php

namespace app\admin\model;

use think\Exception;
use think\facade\Request;
use think\Model;
use think\model\concern\SoftDelete;

//权限组
class AuthGroup extends Model
{
    protected $pk = 'id';
    use SoftDelete;
    protected $deleteTime = 'delete_time';

//权限组列表
    public static function authGroupInfo()
    {
        $list = AuthGroup::select()->toArray();
        return $list;
    }

    //权限组列表添加
    public static function authGroupAddInfo($post)
    {
        if (Request::isPost()) {
            try {
                $res = AuthGroup::insert($post);
            } catch (Exception $e) {
                $res = false;
            }
            return $res;
        } else {
            $rule = AuthRule::select()->toArray();
            return $rule;
        }

    }

    //权限组列表修改
    public static function authGroupEditInfo($param)
    {
        if (Request::isPost()) {
            try {
                $res = AuthGroup::update($param);
            } catch (Exception $e) {
                $res = false;
            }
            return $res;
        } else {
            $find = AuthGroup::find($param['id'])->toArray();
            return $find;
        }
    }

    //权限组删除
    public static function authGroupDelInfo($get)
    {
        try {
            $res = AuthGroup::destroy($get['id']);
        } catch (Exception $e) {
            $res = false;
        }
        return $res;

    }


}